﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tenebrous_Manor.SceneManager
{
    class SceneManager
    {
        public bool changingScene = false;
        public float alpha = 0;
        private bool fadeOut = false;
        private sceneType nextScene;

        public sceneType usingScene;

        public enum sceneType
        {
            TITLE,
            ENTRANCE_CUTSCENE,
            GAME,
            CONTROLS,
            CREDITS,
            MIRROR_CUTSCENE,
            END_CUTSCENE,
            GAMEOVER
        }

        public SceneManager()
        {
            usingScene = sceneType.TITLE;
            nextScene = sceneType.TITLE;
        }

        public void Update()
        {
            if (changingScene)
            {
                if (alpha >= 1 && fadeOut)
                {
                    fadeOut = false;
                    usingScene = nextScene;
                }
                else if (alpha <= 0 && !fadeOut)
                {
                    changingScene = false;
                }
                if (fadeOut)
                {
                    alpha += 0.02f;
                }
                else//fade in
                {
                    alpha -= 0.02f;
                }
            }
        }

        public void changeTo(sceneType nextScene)
        {
            this.nextScene = nextScene;
            changingScene = true;
            fadeOut = true;
        }
    }
    
}
